app.controller('ServiceDurationModalCtrl', function ($scope, $filter, $modalInstance, toaster, param) {

	$scope.submitting = false;
	$scope.param = param;
	if ($scope.param.data == null) {
		$scope.param.data = {};
	}

	$scope.param.data.start = $filter("date")($scope.param.data.start, "HH:mm:ss");
	$scope.param.data.end = $filter("date")($scope.param.data.end, "HH:mm:ss");

	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			var start = $scope.param.data.start;
			var date1 = new Date("1970/1/1 " + start);
			var end = $scope.param.data.end;
			var date2 = new Date("1970/1/1 " + end);
			$scope.param.data.start = date1;
			$scope.param.data.end = date2;
			$modalInstance.close($scope.param);
		}
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
		$scope.submitting = false;
	};
});